package com.epmis.epmis.controller;

import com.epmis.epmis.Service.ExamineService;
import com.github.pagehelper.PageInfo;
import org.springframework.data.relational.core.sql.In;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@Controller
public class ExamineController {
    @Resource
    ExamineService examineService;

    @PostMapping("/findMyApplicant")
    @ResponseBody
    public PageInfo<HashMap<String, Object>> findMyApplicant(@RequestBody HashMap<String, Object> map) {
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        int id = Integer.valueOf((String)map.get("id"));
        return examineService.findMyApplicant(pageCode,pageSize,id);
    }

    @PostMapping("/findMyApplicantComplete")
    @ResponseBody
    public PageInfo<HashMap<String, Object>> findMyApplicantComplete(@RequestBody HashMap<String, Object> map) {
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        int id = Integer.valueOf((String)map.get("id"));
        return examineService.findMyApplicantComplete(pageCode,pageSize,id);
    }

    @PostMapping("/SearchMyApplicant")
    @ResponseBody
    public PageInfo<HashMap<String, Object>> SearchMyApplicant(@RequestBody HashMap<String, Object> map) {
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        int id = Integer.valueOf((String)map.get("id"));
        String content = (String) map.get("content");
        return examineService.SearchMyApplicant(pageCode,pageSize,id,content);
    }

    @PostMapping("/findMyExamine")
    @ResponseBody
    public PageInfo<HashMap<String, Object>> findMyExamine(@RequestBody HashMap<String, Object> map) {
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        int id = Integer.valueOf((String)map.get("id"));
        return examineService.findMyExamine(pageCode,pageSize,id);
    }

    @PostMapping("/findMyExamineComplete")
    @ResponseBody
    public PageInfo<HashMap<String, Object>> findMyExamineComplete(@RequestBody HashMap<String, Object> map) {
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        int id = Integer.valueOf((String)map.get("id"));
        return examineService.findMyExamineComplete(pageCode,pageSize,id);
    }

    @PostMapping("/SearchMyExamine")
    @ResponseBody
    public PageInfo<HashMap<String, Object>> SearchMyExamine(@RequestBody HashMap<String, Object> map) {
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        int id = Integer.valueOf((String)map.get("id"));
        String content = (String) map.get("content");
        return examineService.SearchMyExamine(pageCode,pageSize,id,content);
    }

    @PostMapping("/getExamineMessages")
    @ResponseBody
    public HashMap<String,Object> getExamineMessages(@RequestBody HashMap<String,Object> map){
        int id = (int) map.get("id");
        return examineService.getExamineMessages(id);
    }

    @PostMapping("/createExamineActivity")
    @ResponseBody
    public int createExamineActivity(@RequestBody HashMap<String,Object> map){
        int id = (int) map.get("id");
        int enterpriseId =  Integer.valueOf((String) map.get("enterpriseId"));
        int userId = Integer.valueOf((String)map.get("userId"));
        return examineService.createExamineActivity(id,enterpriseId,userId);
    }

    @PostMapping("/getExamineActivity")
    @ResponseBody
    public List<HashMap<String,Object>> getExamineActivity(@RequestBody HashMap<String,Object> map){
        int id = (int) map.get("id");
        return examineService.getExamineActivity(id);
    }

    @PostMapping("/agreeExamine")
    @ResponseBody
    public int agreeExamine(@RequestBody HashMap<String,Object> map){
        int id = (int) map.get("id");
        int userId = Integer.valueOf((String)map.get("userId"));
        int enterpriseId = Integer.valueOf((String)map.get("enterpriseId"));
        return examineService.agreeExamine(id,userId,enterpriseId);
    }

    @PostMapping("/backExamine")
    @ResponseBody
    public int backExamine(@RequestBody HashMap<String,Object> map){
        int id = (int) map.get("id");
        int enterpriseId = Integer.valueOf((String)map.get("enterpriseId"));
        return examineService.backExamine(id,enterpriseId);
    }

    @PostMapping("/refuseExamine")
    @ResponseBody
    public int refuseExamine(@RequestBody HashMap<String,Object> map){
        int id = (int) map.get("id");
        int userId = Integer.valueOf((String)map.get("userId"));
        int enterpriseId = Integer.valueOf((String)map.get("enterpriseId"));
        return examineService.refuseExamine(id,userId,enterpriseId);
    }

    @PostMapping("/noticeExamine")
    @ResponseBody
    public int noticeExamine(@RequestBody HashMap<String,Object> map){
        int id = (int) map.get("id");
        int getId = (int)map.get("getId");
        int enterpriseId = Integer.valueOf((String)map.get("enterpriseId"));
        int userId = Integer.valueOf((String)map.get("userId"));
        return examineService.noticeExamine(userId,getId,id,enterpriseId);
    }

    @PostMapping("/deleteExamine")
    @ResponseBody
    public int deleteExamine(@RequestBody HashMap<String,Object> map){
        int id = (int) map.get("id");
        return examineService.deleteExamine(id);
    }
}
